package com.jeff.huawei.example;

import java.util.Scanner;

public class InequalityChecker {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        // 读取输入
        String input = scanner.nextLine();
        String[] parts = input.split(";");

        // 检查是否正确分割了6部分
        if (parts.length != 6) {
            System.err.println("Error: Expected 6 parts, but got " + parts.length);
            return;
        }

        // 解析系数矩阵
        double[][] coefficients = new double[3][5];
        for (int i = 0; i < 3; i++) {
            String[] coeffs = parts[i].split(",");
            if (coeffs.length != 5) {
                System.err.println("Error: Coefficients part " + i + " should have 5 elements, but has " + coeffs.length);
                return;
            }
            for (int j = 0; j < 5; j++) {
                coefficients[i][j] = Double.parseDouble(coeffs[j]);
            }
        }

        // 解析变量数组
        String[] vars = parts[3].split(",");
        if (vars.length != 5) {
            System.err.println("Error: Variables part should have 5 elements, but has " + vars.length);
            return;
        }
        int[] variables = new int[5];
        for (int i = 0; i < 5; i++) {
            variables[i] = Integer.parseInt(vars[i]);
        }

        // 解析目标值数组
        String[] targetsStr = parts[4].split(",");
        if (targetsStr.length != 3) {
            System.err.println("Error: Targets part should have 3 elements, but has " + targetsStr.length);
            return;
        }
        double[] targets = new double[3];
        for (int i = 0; i < 3; i++) {
            targets[i] = Double.parseDouble(targetsStr[i]);
        }

        // 解析约束数组
        String[] constraints = parts[5].split(",");
        if (constraints.length != 3) {
            System.err.println("Error: Constraints part should have 3 elements, but has " + constraints.length);
            return;
        }

        // 判断不等式并计算最大差值
        boolean isSatisfied = true;
        double maxDifference = 0.0;

        for (int i = 0; i < 3; i++) {
            double leftSide = 0.0;
            for (int j = 0; j < 5; j++) {
                leftSide += coefficients[i][j] * variables[j];
            }

            double difference = Math.abs(leftSide - targets[i]);

            if (constraints[i].equals("<")) {
                if (leftSide >= targets[i]) {
                    isSatisfied = false;
                }
            } else if (constraints[i].equals("<=")) {
                if (leftSide > targets[i]) {
                    isSatisfied = false;
                }
            } else if (constraints[i].equals("=")) {
                if (leftSide != targets[i]) {
                    isSatisfied = false;
                }
            } else if (constraints[i].equals(">")) {
                if (leftSide <= targets[i]) {
                    isSatisfied = false;
                }
            } else if (constraints[i].equals(">=")) {
                if (leftSide < targets[i]) {
                    isSatisfied = false;
                }
            }

            maxDifference = Math.max(maxDifference, difference);
        }

        // 输出结果
        System.out.println(isSatisfied + " " + (int) maxDifference);

        scanner.close();
    }
}
